package expression;

import memory.Memory;


public abstract class Expression {
	Memory memory;

	public Expression(Memory memory) {
		super();
		this.memory = memory;
	}

	public abstract int calculate();
}

class Constant extends Expression {
	int value;

	@Override
	public int calculate() {
		return value;
	}

	public Constant(int value, Memory memory) {
		super(memory);
		this.value = value;
	}
}

class Variable extends Expression {

	String name;

	Variable(String name, Memory memory) {
		super(memory);
		this.name = name;
	}

	@Override
	public int calculate() {
		return memory.getValue(name);
	}

}